//
//  WIFIHelper.m
//  TPHelper
//
//  Created by xuqiang on 2020/7/23.
//  Copyright © 2020 xuqiang. All rights reserved.
//

#import "WIFIHelper.h"
#import<SystemConfiguration/CaptiveNetwork.h>

@implementation WIFIHelper
+ (NSString *)ssid

{
//    NSString *wifiName = nil;
//
//    CFArrayRef myArray = CNCopySupportedInterfaces();
//
//    if (myArray != nil) {
//
//    CFDictionaryRef myDict = CNCopyCurrentNetworkInfo((CFStringRef)CFArrayGetValueAtIndex(myArray, 0));
//
//    if (myDict != nil) {
//
//    NSDictionary *dict = (NSDictionary*)CFBridgingRelease(myDict);
//
//    wifiName = [dict valueForKey:@"SSID"];
//
//    }
//
//    }
//
//    NSLog(@"wifiName:%@", wifiName);
//    return wifiName;
    NSString *ssid = @"Not Found";

    CFArrayRef myArray = CNCopySupportedInterfaces();
    if (myArray != nil) {

        CFDictionaryRef myDict = CNCopyCurrentNetworkInfo(CFArrayGetValueAtIndex(myArray, 0));

        if (myDict != nil) {

            NSDictionary *dict = (NSDictionary*)CFBridgingRelease(myDict);

            ssid = [dict valueForKey:@"SSID"];

        }

    }
    return ssid;
    
}

@end
